package com.kll.tv.views.adapter

import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.kll.carolinehmibiz.net.bean.GetAdsResponse
import com.kll.tv.R
import com.kll.tv.databinding.ItemBannerBinding
import com.zhpan.bannerview.BaseBannerAdapter
import com.zhpan.bannerview.BaseViewHolder

class BannerAdapter : BaseBannerAdapter<GetAdsResponse.AdsBean>() {

    override fun bindData(
        holder: BaseViewHolder<GetAdsResponse.AdsBean>?,
        data: GetAdsResponse.AdsBean?,
        position: Int,
        pageSize: Int
    ) {
        val binding: ItemBannerBinding = ItemBannerBinding.bind(holder!!.itemView)
        if (data != null) {
            Glide.with(holder.itemView).load("http://" + data.source).apply(RequestOptions().centerCrop()).into(binding.ivBannerItem)
        }
    }

    override fun getLayoutId(viewType: Int): Int {
        return R.layout.item_banner

    }

}